//Replication data for Shelef, Nadav; Jamison, Anne, 2024, "Replication Data for: Domestic legitimacy, coethnics abroad, and the shape of the homeland", https://doi.org/10.7910/DVN/FWK7IN, Harvard Dataverse

//This do-file replicates Figures A.1 and A.2 only, as they require a different configuration of the data. Please see a separate do-file for the rest of the analysis contained in the appendix. 

//Computed on Stata 17.0 SE

//load data
use "cox data.dta"

//both graphs below require this preamble: 

stset time if potato_any_ModifiedEPR ==1 & colony==0, failure(homeland) exit(time .) origin(time0_minus1) id(id)

stsplit, at(failure)
replace mid_current_tvc= mid_current*ln(_t)
replace priormid_tvc= priormid*ln(_t)
replace coethnic_presence_tek_mod_tvc= coethnic_presence_tek_mod*ln(_t)
replace poly_binary_dem1other0_tvc= poly_binary_dem1other0*ln(_t)
replace econ_value_all_tvc= econ_value_all*ln(_t) 
replace cincrat_updtd_clclpwr_tvc= cincrat_updtd_clclpwr *ln(_t)
replace capital_distance_ln_tvc= capital_distance_ln*ln(_t)
replace global_qtile_tvc= global_qtile*ln(_t)
replace strata2_tvc= strata2*ln(_t)
replace strata3_tvc=  strata3*ln(_t)
replace strata4up_tvc=  strata4up*ln(_t)
replace regimeage_Vdem_tvc= regimeage_Vdem*ln(_t)
replace coethnicXdemocracy_tvc=coethnicXdemocracy*ln(_t)
replace any_jussoli_tvc= any_jussoli*ln(_t)
 
 
 
***********
***********
//Figure A.1: Risk of applying homeland territoriality to lost lands (Cox conditional hazard), combined, other proxies for use of ethnic logics
***********
***********


//panel a, excluded ethnic population
stcox mid_current priormid i.coethnic_presence_tek_mod##c.ln_losingstate_exclpop econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem priormid_tvc econ_value_all_tvc capital_distance_ln_tvc regimeage_Vdem_tvc  strata2_tvc strata3_tvc strata4up_tvc, shared(id) forceshared efron

stcurve, hazard at1(coethnic_presence_tek_mod=1 ln_losingstate_exclpop==-.579818) at2(coethnic_presence_tek_mod=0 ln_losingstate_exclpop==-.579818) at3(coethnic_presence_tek_mod=1 ln_losingstate_exclpop==-27.631) at4(coethnic_presence_tek_mod=0 ln_losingstate_exclpop==-27.631)  legend(label(1 "90{superscript:th} percentile of population" "excluded, Coethnics") label(2 "90{superscript:th} percentile of population" "excluded, no coethnics")label(3 "10{superscript:th} percentile of population" "excluded, Coethnics")label(4 "10{superscript:th} percentile of population" "excluded, no coethnics")) xtitle("analysis time (years)") lwidth(thick thick thick thick) lpattern(solid longdash solid longdash) lcolor(black black gray gray) graphregion(color(white)) bgcolor(white) ylabel(,nogrid)

//panel b, GDP growth
stcox mid_current priormid i.coethnic_presence_tek_mod##c.gdpgrowth100 econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem regimeage_Vdem_tvc  strata2_tvc strata3_tvc strata4up_tvc, shared(id) forceshared efron

stcurve, hazard at1(coethnic_presence_tek_mod=1 gdpgrowth100 =-9) at2(coethnic_presence_tek_mod=0 gdpgrowth100 =-9) at3(coethnic_presence_tek_mod=1 gdpgrowth100=8) at4(coethnic_presence_tek_mod=0 gdpgrowth100=8)  legend(label(1 "Low GDP Growth" "(10{superscript:th} percentile)," "Coethnics") label(2 "Low GDP Growth" "(10{superscript:th} percentile)," "No coethnics") label(3 "High GDP Growth" "(90{superscript:th} percentile)," "Coethnics")label(4 "High GDP Growth" "(90{superscript:th} percentile)," "no coethnics")) xtitle("analysis time (years)") lwidth(thick thick thick thick) lpattern(solid longdash solid longdash) lcolor(black black gray gray) graphregion(color(white)) bgcolor(white) ylabel(,nogrid)




**************
**************
//Figure A.2: Risk of applying homeland territoriality where states use nationalist ideology (Cox conditional hazard)
**************
**************

//First figure 

stcox mid_current priormid i.coethnic_presence_tek_mod##legitideol_34_nationalism cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem , shared(id) forceshared efron
estat phtest, rank detail

*TVC needed (.1): priormid capital_distance_ln regimeage_Vdem  strata2 strata3 strata4up

stcox mid_current priormid i.coethnic_presence_tek_mod##i.legitideol_34_nationalism econ_value_all cincrat_updtd_clclpwr capital_distance_ln global_qtile strata2 strata3 strata4up regimeage_Vdem priormid_tvc  capital_distance_ln_tvc  regimeage_Vdem_tvc strata2_tvc strata3_tvc  strata4up_tvc, shared(id) forceshared efron 

estimates store nationalism_nodecol
estimates save "nationalism_nodecol" 

stcurve, hazard at1(coethnic_presence_tek_mod=1 legitideol_34_nationalism=1) at2(coethnic_presence_tek_mod=1 legitideol_34_nationalism=0)   legend(label(1 "Nationalist legitimization to" "a large extent or higher," "Coethnics") label(2 "Nationalist legitimization to" "less than a large extent," "Coethnics")) xtitle("analysis time (years)") lwidth(thick thick) lcolor(black black) lpattern(solid dash ) graphregion(color(white)) bgcolor(white)

//Second figure 

stcurve, hazard at1(coethnic_presence_tek_mod=1 legitideol_34_nationalism=1) at2(coethnic_presence_tek_mod=1 legitideol_34_nationalism=0)   legend(label(1 "Nationalist legitimization to" "a large extent or higher," "Coethnics") label(2 "Nationalist legitimization to" "less than a large extent," "Coethnics")) xtitle("analysis time (years)") lwidth(thick thick) lcolor(black black) lpattern(solid dash ) graphregion(color(white)) bgcolor(white)



